/**
 * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package org.openwork.portlet.skillmanagement.service.impl;

import java.util.List;

import org.openwork.portlet.skillmanagement.model.SkillCategory;
import org.openwork.portlet.skillmanagement.permission.SkillCategoryPermissionUtil;
import org.openwork.portlet.skillmanagement.permission.SkillUserActions;
import org.openwork.portlet.skillmanagement.service.SkillCategoryLocalServiceUtil;
import org.openwork.portlet.skillmanagement.service.base.SkillCategoryServiceBaseImpl;

import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;

/**
 * <a href="SkillCategoryServiceImpl.java.html"><b><i>View Source</i></b></a>
 *
 * @author samuelgmartinez
 */
public class SkillCategoryServiceImpl extends SkillCategoryServiceBaseImpl {

	public SkillCategory addSkillCategory(String name, long userId, long groupId)
			throws PortalException, SystemException {
		SkillCategoryPermissionUtil.canCreate(getPermissionChecker(), groupId);

		return SkillCategoryLocalServiceUtil.addSkillCategory(name, userId, groupId);
	}

	public SkillCategory updateSkillCategory(long pk, String name, long userId,
			long groupId) throws PortalException, SystemException {
		SkillCategoryPermissionUtil.
			check(getPermissionChecker(), pk, SkillUserActions.UPDATE);
		
		return SkillCategoryLocalServiceUtil.updateSkillCategory(pk, name, userId, groupId); 
	}
	
	public void deleteSkillCategory(long pk) throws PortalException, SystemException {
		SkillCategoryPermissionUtil.
			check(getPermissionChecker(), pk, SkillUserActions.DELETE);
		
		SkillCategoryLocalServiceUtil.deleteSkillCategory(pk); 
	}
	
	public List<SkillCategory> search(long groupId) throws SystemException, PortalException {
		return skillCategoryPersistence.findByGroupId(groupId);
	}
	
	public int searchCount(long groupId) throws SystemException, PortalException {
		return skillCategoryPersistence.countByGroupId(groupId);
	}
	
	//TODO: implement this
	public List<SkillCategory> search(long[] groupId) throws SystemException, PortalException {
		return null;
	}
	
	//TODO: implement this	
	public int searchCount(long[] groupId) throws SystemException, PortalException {
		return 0;
	}
}